<template>
  <div class="common-search-form-component">
    <a-card class="search-card" :bordered="false">
      <template #title>
        <a-space align="center">
          <a-button @click="handleBackToType" type="link">
            <template #icon><ArrowLeftOutlined /></template>
          </a-button>
          <span>{{ $t('dict.currentType') }} {{ dictTypeName }}</span>
        </a-space>
      </template>
      <a-form :model="queryParams">
        <a-row :gutter="16">
          <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
            <a-form-item :label="$t('dict.label')">
              <a-input v-model:value="queryParams.dictLabel" :placeholder="$t('dict.labelPlaceholder')" allow-clear />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
            <a-form-item :label="$t('dict.value')">
              <a-input v-model:value="queryParams.dictValue" :placeholder="$t('dict.valuePlaceholder')" allow-clear />
            </a-form-item>
          </a-col>
          <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
            <a-form-item :label="$t('dict.status')">
              <a-select v-model:value="queryParams.status" :placeholder="$t('common.selectStatusPlaceholder')" allow-clear>
                <a-select-option value="0">{{ $t('common.enabled') }}</a-select-option>
                <a-select-option value="1">{{ $t('common.disabled') }}</a-select-option>
              </a-select>
            </a-form-item>
          </a-col>
        </a-row>
      </a-form>
    </a-card>
  </div>
</template>

<script lang="ts" setup>

defineOptions({
  name: 'DataSearchForm'
})

// Props定义
withDefaults(defineProps<{
  queryParams: {
    dictType?: string
    dictLabel?: string
    dictValue?: string
    status?: '0' | '1'
  }
  dictTypeName?: string
}>(), {
  queryParams: () => ({}),
  dictTypeName: undefined
})

// Emits定义
const emit = defineEmits<{
  (e: 'back'): void
}>()

// 返回到字典类型列表
const handleBackToType = () => {
  emit('back')
}

</script>

<style lang="scss" scoped>
@import '@/assets/styles/views/common.scss';
</style> 